package com.example.tree.controller;


import com.example.common.response.R;
import com.example.tree.bean.MenuTree;
import com.example.tree.service.MenuService;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ZhengDing
 * @since 2022-02-21 19:49:45
 */
@RestController
@RequestMapping("/tree/menu")
public class MenuController {
    
    @Resource
    private MenuService menuService;
    
    @RequestMapping("getTreeByPid")
    public R<List<MenuTree>> getTreeByPid(Integer pid) {
        if (pid == null) {
            pid = 0;
        }
        List<MenuTree> data = menuService.getTreeByPid(pid);
        return R.OK(data);
    }
    
    @RequestMapping("getRootTree")
    public R<List<MenuTree>> getRootTree() {
        List<MenuTree> data = menuService.getRootTree();
        return R.OK(data);
    }
    
    @RequestMapping("getMainTree")
    public R<List<MenuTree>> getMainTree() {
        List<MenuTree> data = menuService.getMainTree();
        return R.OK(data);
    }
    
}
